package com.baizhi.controller;

import com.baizhi.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;

/**
 * 用来测试创建对象
 */
@RestController
public class DemoController {

    @Autowired  // 默认根据类型注入
    @Qualifier("demoService")   // 修改注入方式，根据名称注入
    private DemoService demoService;

    @Autowired
    private Calendar calendar;

    @RequestMapping("demo")
    public String demo() {
        System.out.println("demo ok");
        demoService.demo();
        return "demo ok";
    }

    @RequestMapping("demo2")
    public String demo2() {
        // Calendar calendar = Calendar.getInstance();
        System.out.println("当前日期：" + calendar.getTime());
        return "demo2 ok";
    }
}
